<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        // 当文档加载完毕 然后就执行{}里面的代码
        window.onload = function () {

            // NodeList 可以认为是类似于数组的一个对象
            var oDiv1 = document.getElementsByName("haha");


            // [object NodeList]
            alert(oDiv1);
            alert(oDiv1.length);
            alert(oDiv1.item(0));//通过下标索引取出一个对象
            alert(oDiv1[1]);//[object HTMLParagraphElement]
            
        }
    </script>
</head>

<body>


    <div class="box" name = "haha">哈哈哈哈哈哈</div>
    <p class="box" name = "haha">哈哈哈哈哈哈</p>
   


</body>

</html>